//
//  DownloadHelper.h
//  mcf
//
//  Created by yuike6 yuike6 on 12-2-8.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "DownloaderTask.h"
//#import "header.h"

@class DownloadRecvData;
@class YTaskPool;
//@class DownloaderTask;
@protocol DownloadHelperDelegate <NSObject>
@optional
- (void) didReceiveDataFinish: (NSData *) theData;
- (void) didReceiveFilename: (NSString *) aName;
- (void) dataDownloadFailed: (NSString *) reason;
- (void) dataDownloadAtPercent: (NSNumber *) aPercent;
@end

@interface DownloadHelper : NSObject<DownloaderTaskDelegate>
{
//	NSURLResponse *response_;   
    DownloadRecvData * recvData_; //NSMutableData *data_; 
    
//	NSURL * urlString_;
//	NSURLConnection *urlconnection_;
    
	id <DownloadHelperDelegate> delegate_;
	BOOL isDownloading_;
    
    YTaskPool * downloaderPool_;
    DownloaderTask * downloaderTask_;
    
    BOOL isCanceling;
    NSLock * callBackLocak_;
}
//@property (nonatomic, retain) NSURLResponse *response;
//@property (nonatomic, retain) NSURLConnection *urlconnection;

@property (nonatomic, retain) DownloadRecvData *data;
//@property (nonatomic, retain) NSURL *urlString;

@property (nonatomic, assign) id<DownloadHelperDelegate> delegate;
@property (nonatomic, assign) BOOL isDownloading;

@property (nonatomic, retain) YTaskPool * downloaderPool;
@property (nonatomic, retain) DownloaderTask * downloaderTask;

@property (nonatomic, assign) BOOL isCanceling;
@property (nonatomic, retain) NSLock * callBackLocak;

- (void) downloadUrl:(NSString *) aURLString;
- (void) download:(NSURL *) url;
- (void) cancel;
@end





